package com.grgbanking.it.wx.common;

import net.sf.json.JSONObject;

import com.grgbanking.it.common.HttpConnection;

/**
 * Token码
 * 
 * Token
 * 
 * @author 潘广伟
 * @Email p_3er@qq.com
 * @Date 2015-1-8 上午8:03:45
 * 
 * @version 1.0.0
 *
 */
public class Token {
	/**
	 * 获取token码
	 * getToken
	 * 
	 * @return
	 * @throws Exception 
	 * @exception 
	 * @since  1.0.0
	 */
	public static String getToken(HttpConnection httpConnection) throws Exception {
		StringBuffer url = new StringBuffer(WXConstant.TOKEN_URL);
		url.append("?corpid=").append(WXConstant.CORPID);
		url.append("&corpsecret=").append(WXConstant.CORPSECRET);
		String responeText = httpConnection.sendGet(url.toString());

		JSONObject obj = JSONObject.fromObject(responeText);
		
		return obj.getString("access_token");
	}
}
